﻿#if !defined(linux) && !defined(__linux) && !defined(__linux__)
#error "Support for Linux!"
#endif

#include <stdio.h>
#include <stdlib.h>

/*
 * Usage: stty [-F DEVICE | --file=DEVICE] [SETTING]...
 *   or:  stty [-F DEVICE | --file=DEVICE] [-a|--all]
 *   or:  stty [-F DEVICE | --file=DEVICE] [-g|--save]
 * Input settings
 * [-]igncr  [取消]设置忽略回车
 * [-]iuclc  [取消]设置大写字符转换为小写
 * Output settings
 * [-]ouclc  [取消]设置小写字符转换为大写
 * Local settings
 * [-]echo   [取消]设置输入回显
 * [-]icanon [取消]设置结束符，匹配立即读取
 */

int getch(void)
{
	system("stty -echo");
	system("stty -icanon");
	int key = getchar();
	system("stty icanon");
	system("stty echo");
	return key;
}

int getche(void)
{
	system("stty -icanon");
	int key = getchar();
	system("stty icanon");
	return key;
}
